#include <bits/stdc++.h>
using namespace std;
int n, m;
int ma[201][201];

int di[] = {-1, 1, 0, 0};
int dj[] = {0, 0, -1, 1};

struct P {
  int x;
  int y;
};

void search(int i, int j) {
  queue<P> Q;
  Q.push({i, j});
  ma[i][j] = 0;
  while (!Q.empty()) {
    P head = Q.front();
    Q.pop();
    for (int k = 0; k < 4; k++) {
      int newx = head.x + di[k];
      int newy = head.y + dj[k];
      if (ma[newx][newy] == 1) {
        Q.push({newx, newy});
        ma[newx][newy] = 0;
      }
    }
  }
}
int main() {
  cin >> n >> m;

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char c;
      cin >> c;
      if (c == '.')
        ma[i][j] = 1;
    }
  }

  int a = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (ma[i][j] == 1) {
        a++;
        search(i, j);
      }
    }
  }
  cout << a << endl;
  return 0;
}
